/* Yet Another Experimental Software Renderer
 *
 * Copyright (c) 2010 Pawel "Hery" Dziepak
 */

#ifndef DEBUG_OUTPUT_H_
#define DEBUG_OUTPUT_H_

#include "executor.h"

#include <vector>

namespace yasl {
	class debug_output : public executor {
	public:
		void define_function(function f) {
			func.push_back(f);
		}

		void flush(int) {
			for (int i = 0; i < func.size(); i++) {
				printf("Function:\t%d\nReturns:\t%d\nArguments:\n", func[i].name, func[i].ret_type);
				for (int j = 0; j < func[i].arguments.size(); j++)
					printf("\tArgument:\t%d\tType:\t%d\n", func[i].arguments[j].name, func[i].arguments[j].type);
				printf("Does:\n");
				for (int j = 0; j < func[i].code.size(); j++) {
					printf("\tInstruction:\t%d\n", func[i].code[j].type);
					printf("\tReturns to:\t%d\n", func[i].code[j].ret_to);
					for (int k = 0; k < func[i].code[j].arguments.size(); k++)
						printf("\t\tArgument:\t%d\tReference:%d\n", func[i].code[j].arguments[k].value, func[i].code[j].arguments[k].ref);
				}
			}
		}
	private:
		std::vector<function> func;
	};
}

#endif